package com.xiaoyang.lotterysystem.dao.mapper;

import com.xiaoyang.lotterysystem.dao.dataobject.PrizeDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PrizeMapper {
    @Insert("insert into prize (name, description, price, image_url) " +
            " values (#{name}, #{description}, #{price}, #{imageUrl})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id" )
    Integer insert(PrizeDO prizeDO);

    @Select("select count(1) from prize")
    Integer count();

    @Select("select * from prize order by id desc limit #{offset}, #{pageSize}")
    List<PrizeDO> selectPrizeList(@Param("offset") Integer offset,
                                  @Param("pageSize") Integer pageSize);

    List<Long> selectExistByIds(@Param("items") List<Long> ids);

    List<PrizeDO> batchSelectByIds(@Param("items") List<Long> ids);

    @Select("select * from prize where id = #{id}")
    PrizeDO selectById(@Param("id") Long id);
}
